<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('ruku列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>生成日期：</label>
                            <input type="text" class="time-input" id="startTime1" placeholder="开始时间"
                                   name="params[beginXiadanriqi]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime1" placeholder="结束时间"
                                   name="params[endXiadanriqi]"/>
                        </li>
                        <li class="select-time">
                            <label>入库日期：</label>
                            <input type="text" class="time-input" id="startTime2" placeholder="开始时间"
                                   name="params[beginRukuriqi]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime2" placeholder="结束时间"
                                   name="params[endRukuriqi]"/>
                        </li>

                        <li>
                            <label>商品名称：</label>
                            <input type="text" name="shangpinbianhao" list="shangpinlist"/>
                            <datalist id="shangpinlist" th:with="type=${@shangpinguanliMapper.selectShangpingList()}">
                                <option th:each="lists : ${type}"
                                        th:text="${lists.getShangpinleibie()+'|'+lists.getShangpinguigekuan()+'*'+lists.getShangpinguigegao()+'|'+lists.getShangpinkaixiang()}"
                                        th:value="${lists.getShangpinming()}"></option>
                            </datalist>
                        </li>
                        <li>
                            <label>商品数量：</label>
                            <input type="text" name="shangpinshuliang"/>
                        </li>
                        <li>
                            <label style="width: auto;">下单操作人：</label>
                            <input type="text" name="xiadanren"/>
                        </li>
                        <li>
                            <label style="width: auto;">入库操作人：</label>
                            <input type="text" name="rukuren"/>
                        </li>
                        <li>
                            <label>总金额：</label>
                            <input type="text" name="zongjine"/>
                        </li>
                        <li>
                            <label>备注：</label>
                            <input type="text" name="beizhu"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jinchuguanli:ruku:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="jinchuguanli:ruku:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="jinchuguanli:ruku:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
<!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jinchuguanli:ruku:export">-->
<!--                <i class="fa fa-download"></i> 导出-->
<!--            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('jinchuguanli:ruku:edit')}]];
    var removeFlag = [[${@permission.hasPermi('jinchuguanli:ruku:remove')}]];
    var prefix = ctx + "jinchuguanli/ruku";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "入库列表",
            showColumns: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id主键',
                    visible: false
                },
                {
                    field: 'xiadanriqi',
                    title: '生成日期',
                    align: "center",
                },
                {
                    field: 'rukuriqi',
                    title: '入库日期',
                    align: "center",
                },
                {
                    field: 'xiadanren',
                    title: '下单操作人',
                    align: "center",
                },
                {
                    field: 'rukuren',
                    title: '入库操作人',
                    align: "center",
                },
                {
                    field: 'shangpin',
                    title: '商品',
                    align: "center",
                    formatter: function (value, row, index) {
                        var action = []
                        // console.log(value)
                        var divstr = "<div style='display: grid;align-items: center;" +
                            "justify-content: center;grid-template-columns: repeat(1,0.85fr)'><table><tbody>"
                        for (let i = 0; i < value.length; i++) {
                            let colName = '';
                            let colSize = '';
                            let collagen = '';
                            let colNum = '';
                            colName = value[i].shangpinming
                            if (value[i].shangpinguigekuan !== 0) {
                                colSize = value[i].shangpinguigekuan + " * " + value[i].shangpinguigegao
                                    + "  " + value[i].shangpinkaixiang
                            }
                            collagen = value[i].shangpinjinhuojia
                            colNum = value[i].shangpinshuliang

                            divstr += "<tr>" +
                                "<td style='border-bottom: 0 \!important'>商品名：" + colName + "</td>" +
                                "<td style='border-bottom: none \!important'>尺寸：" + colSize + "</td>" +
                                "</tr>" +
                                "<tr>" +
                                "<td style='border-top: none \!important'>进货价格：" + collagen + "</td>" +
                                "<td style='border-top: none \!important'>进货数量：" + colNum + "</td>" +
                                "</tr>"
                        }
                        divstr += "</tbody></table></div>"
                        action.push(divstr)
                        return action.join('');
                    }
                },
                // {
                //     field: 'shangpinshuliang',
                //     title: '商品数量'
                // },
                {
                    field: 'zongjine',
                    title: '总金额',
                    align: "center",
                },
                {
                    field: 'beizhu',
                    title: '备注',
                    align: "center",
                },
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                // }
                {
                    field: 'shifouzhixing',
                    title: '是否已出库',
                    align: "center",
                    formatter: function (value, row, index) {
                        var action = []
                        action.push(Number(value) === 0 ? "未执行" : "已执行")
                        return action.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>